package com.y.architecture.base_tab;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager;

import com.y.architecture.base_header.BaseHeaderActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by youjingjing on 2017/11/29.
 */

public abstract class BaseTabPagerActivity<T extends IBaseTabPageContact.IPageTitle> extends BaseHeaderActivity implements IBaseTabPageContact.IBaseTabPageView<T>{

    protected TabLayout mTabLayout;
    protected ViewPager mPager;
    protected List<T> mItems = new ArrayList<>();

    private BaseTabPagerHelper<T> mBaseTabPagerHelper;

    @Override
    public void initHeader(Bundle savedInstanceState) {
        super.initHeader(savedInstanceState);
        initTabPager(savedInstanceState);
    }
    @Override
    public void initTabPager(Bundle saveInstanceStatus) {
        mBaseTabPagerHelper = new BaseTabPagerHelper<>(this);

        mTabLayout = mBaseTabPagerHelper.setTabLayout();
        mPager = mBaseTabPagerHelper.setPager();
        getData();
    }

    @Override
    public FragmentManager getAFFragmentManager() {
        return getSupportFragmentManager();
    }

    @Override
    public int getPagerId() {
        return mBaseTabPagerHelper.getDefaultPageId();
    }

    @Override
    public int getTabId() {
        return mBaseTabPagerHelper.getDefaultTabId();
    }

    @Override
    public List<T> getItems() {
        return mItems;
    }

    @Override
    public void createPager() {
        mBaseTabPagerHelper.createPager();
    }

    @Override
    public void onTabSelected(TabLayout.Tab tab) {

    }

    @Override
    public void onTabReselected(TabLayout.Tab tab) {

    }

    @Override
    public void onTabUnselected(TabLayout.Tab tab) {

    }
}
